home *** CD-ROM | disk | FTP | other *** search
- #ifndef __MOREFILESEXTRAS__
- #include <MoreFilesExtras.h>
- #endif
-
- #ifndef __MOREFILES__
- #include <MoreFiles.h>
- #endif
-
- #ifndef __FSPCOMPAT__
- #include <FSpCompat.h>
- #endif
-
-
- #include "FabWmemman.h"
- #include "Logger.h"
-
-
- IOParam *OpenLogFile(const FSSpec *spec, OSType creator, OSErr *retErr, Boolean exists)
- {
- IOParam *thePB/* = nil*/;
- short refNum = 0;
- OSErr err = noErr;
-
- if (thePB = ffcalloc(sizeof(ParamBlockRec))) {
- if (exists == false)
- err = FSpCreateCompat(spec, creator, 'TEXT', smCurrentScript);
-
- if (err == noErr) {
- if ((err = FSpOpenAware(spec, dmWrDenyWr, &refNum)) == noErr) {
- // thePB->ioCompletion = nil;
- thePB->ioRefNum = refNum;
- thePB->ioPosMode = fsFromLEOF | noCacheMask;
- }
- else {
- (void) FSpDeleteCompat(spec);
- SAFEDESTROY(ffree, IOParam *, thePB, IOParam *)
- }
- }
- else {
- SAFEDESTROY(ffree, IOParam *, thePB, IOParam *)
- }
- }
- else
- err = appMemFullErr;
-
- *retErr = err;
- return thePB;
- }
-
- void WriteToLogFile(IOParam *thePB, void *buffer, UInt32 bufSize)
- {
- thePB->ioBuffer = buffer;
- thePB->ioReqCount = bufSize;
- thePB->ioPosOffset = 0;
- (void) PBWriteSync((ParmBlkPtr)thePB);
- }
-
-
- void CloseLogFile(IOParam *thePB)
- {
- (void) FSClose(thePB->ioRefNum);
- ffree(thePB);
- }
-
-